﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace TextEditorDP
{
    public class ChangeFontCommand: Command
    {
        CRichTextBox editor;
        Font font;
        string history;
        public ChangeFontCommand(ref CRichTextBox editor, Font font)
        {
            this.editor = editor;
            this.font = font;
        }

        #region Command Members

        public bool Execute()
        {
            history = editor.Rtf;
            // Insert text with a little formatting
            editor.SelectionFont = font;
            return true;
        }

        public void UnExecute()
        {
            editor.Rtf = history;
        }

        public bool CanUndo()
        {
            return true;
        }

        #endregion
    }
}
